package com.example.xlsx;

import com.mysql.cj.result.Row;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileInputStream;
import java.io.FileOutputStream;

//行上下移动
public class DeleteExcel {

        public static void main(String[] args) {
            /**
             * @param args
             */
            try{

                FileInputStream is = new FileInputStream("D:/study/code/chuangzhixinghandocument/wps/1628405575873info.xlsx");

                //xlsx
                XSSFWorkbook workbook = new XSSFWorkbook(is);
                XSSFSheet sheet=workbook.getSheetAt(0);  //获取到工作表，因为一个excel可能有多个工作表

                //xls
//                HSSFWorkbook workbook = new HSSFWorkbook(is);
//                HSSFSheet sheet = workbook.getSheetAt(0);


                //行上下移动
                sheet.shiftRows(14, 15,1);
//                startRow  要移动的开始行
//                endRow  要移动的结束行
//                n 要移动的行数  n为负数代表向上移动
//                copyRowHeight  是否复制行高
//                resetOriginalRowHeigth 是否充值行高

                FileOutputStream os = new FileOutputStream("D:/study/code/chuangzhixinghandocument/wps/1628405575873info.xlsx");

                workbook.write(os);

                is.close();

                os.close();

            } catch(Exception e) {

                e.printStackTrace();
            }
        }
    }

